/*
 * Powered By [rapid-framework]
 * Web Site: http://www.rapid-framework.org.cn
 * Google Code: http://code.google.com/p/rapid-framework/
 * Since 2008 - 2013
 */

package org.teacup.eightdays.dao;

import java.util.*;

import javacommon.base.*;
import javacommon.util.*;

import cn.org.rapid_framework.util.*;
import cn.org.rapid_framework.web.util.*;
import cn.org.rapid_framework.page.*;
import cn.org.rapid_framework.page.impl.*;

import org.teacup.eightdays.model.*;
import org.teacup.eightdays.dao.*;
import org.teacup.eightdays.service.*;
import org.teacup.eightdays.vo.query.*;

/**
 * @author Abner email:521yexu2008(a)163.com
 * @version 1.0
 * @since 1.0
 */

import static cn.org.rapid_framework.util.ObjectUtils.*;
import org.springframework.stereotype.Repository;

@Repository
public class MemberinfoDao extends BaseHibernateDao<Memberinfo,java.lang.Long>{

	public Class getEntityClass() {
		return Memberinfo.class;
	}
	
	public Page findPage(MemberinfoQuery query) {
        StringBuilder sqlBuilder = new StringBuilder("select t from Memberinfo t where 1=1 ");
        if(isNotEmpty(query.getMemberinfoId())) {
            sqlBuilder.append(" and  t.memberinfoId = :memberinfoId ");
        }
        if(isNotEmpty(query.getLoginname())) {
            sqlBuilder.append(" and  t.loginname = :loginname ");
        }
        if(isNotEmpty(query.getLoginPassword())) {
            sqlBuilder.append(" and  t.loginPassword = :loginPassword ");
        }
        if(isNotEmpty(query.getSex())) {
            sqlBuilder.append(" and  t.sex = :sex ");
        }
        if(isNotEmpty(query.getStatus())) {
            sqlBuilder.append(" and  t.status = :status ");
        }
        if(isNotEmpty(query.getDepartmentId())) {
            sqlBuilder.append(" and  t.departmentId = :departmentId ");
        }
        if(isNotEmpty(query.getClassName())) {
            sqlBuilder.append(" and  t.className = :className ");
        }
        if(isNotEmpty(query.getBrithdayBegin())) {
            sqlBuilder.append(" and  t.brithday >= :brithdayBegin ");
        }
        if(isNotEmpty(query.getBrithdayEnd())) {
            sqlBuilder.append(" and  t.brithday <= :brithdayEnd ");
        }
        if(isNotEmpty(query.getEmail())) {
            sqlBuilder.append(" and  t.email = :email ");
        }
        if(isNotEmpty(query.getQqNumber())) {
            sqlBuilder.append(" and  t.qqNumber = :qqNumber ");
        }
        if(isNotEmpty(query.getMobileNumber())) {
            sqlBuilder.append(" and  t.mobileNumber = :mobileNumber ");
        }
        if(isNotEmpty(query.getName())) {
            sqlBuilder.append(" and  t.name = :name ");
        }
        if(isNotEmpty(query.getAddress())) {
            sqlBuilder.append(" and  t.address = :address ");
        }
        if(isNotEmpty(query.getMobileApproveStatus())) {
            sqlBuilder.append(" and  t.mobileApproveStatus = :mobileApproveStatus ");
        }
        if(isNotEmpty(query.getEmailApproveStatus())) {
            sqlBuilder.append(" and  t.emailApproveStatus = :emailApproveStatus ");
        }
        if(isNotEmpty(query.getRegTimeBegin())) {
            sqlBuilder.append(" and  t.regTime >= :regTimeBegin ");
        }
        if(isNotEmpty(query.getRegTimeEnd())) {
            sqlBuilder.append(" and  t.regTime <= :regTimeEnd ");
        }
        if(isNotEmpty(query.getNowLoginTimeBegin())) {
            sqlBuilder.append(" and  t.nowLoginTime >= :nowLoginTimeBegin ");
        }
        if(isNotEmpty(query.getNowLoginTimeEnd())) {
            sqlBuilder.append(" and  t.nowLoginTime <= :nowLoginTimeEnd ");
        }
        if(isNotEmpty(query.getLastLoginTimeBegin())) {
            sqlBuilder.append(" and  t.lastLoginTime >= :lastLoginTimeBegin ");
        }
        if(isNotEmpty(query.getLastLoginTimeEnd())) {
            sqlBuilder.append(" and  t.lastLoginTime <= :lastLoginTimeEnd ");
        }
        if(isNotEmpty(query.getSortColumns())) {
            sqlBuilder.append(" order by :sortColumns ");
        }	
        String sql = sqlBuilder.toString();
		return pageQuery(sql,query);
	}
	

}